library(mlr3)
library(mlr3filters)

# Calculating filter values ----
filter <- FilterJMIM$new()
task <- tsk("iris")
filter$calculate(task)
as.data.table(filter)

# Some filters support changing specific hyperparameters.
filter_cor <- FilterCorrelation$new()
filter_cor$param_set

# change parameter 'method'
filter_cor$param_set$values = list(method = "spearman")
filter_cor$param_set

# Rather than taking the “long” R6 way to create a filter, 
#   there is also a built-in shorthand notation for filter creation:
filter <- flt("cmin")
filter

# Variable Importance Filters ----
library("mlr3learners")
lrn = lrn("classif.ranger", importance = "impurity")

task = tsk("iris")
filter = flt("importance", learner = lrn)
filter$calculate(task)
head(as.data.table(filter), 3)
